********************************************************************************
* Data preparation: Hours variables
********************************************************************************

* uhrsworkly: number of hours per week that respondents usually worked if they worked during the previous calendar year
* topcoded at 99
replace uhrsworkly = . if uhrsworkly == 999

* wkswork1: number of weeks that respondent worked in preceding calendar year (including paid vacation and sick leave)

* Annual hours
gen hours_ann = uhrsworkly*wkswork1
label var hours_ann "Individual annual hours last year"
	
* Annual hours of spouse
rangestat (mean) hours_ann_sp = hours_ann, by(serial) interval(lineno sploc_gen sploc_gen)

* Household annual hours
*egen hours_ann_hh = rowtotal(hours_ann hours_ann_sp), missing
by serial: egen hours_ann_hh = total(hours_ann), missing
by serial: egen hours_ann_max = max(hours_ann), missing

* Household type
gen hh_type = 1 if age_sp == .
replace hh_type = 2 if age_sp != .